home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_gnats.idb / usr / freeware / lib / gnats / contrib / tkgnats / entryDialog.z / entryDialog
Encoding:
Tcl/Tk script  |  1999-04-16  |  1.3 KB  |  50 lines

  1. #!/usr/local/bin/wish -file
  2.  
  3. #
  4. # $Id: entryDialog,v 1.3 1993/11/16 22:19:20 jason Exp $
  5. #
  6.  
  7. proc Lc {s} {return $s}
  8.  
  9. proc EntryDialog {type t msg} {
  10.     global EntryDialog_Value
  11.     catch {destroy .EntryDialog}
  12.     $type $t -borderwidth 4 -relief sunken
  13.     message $t.msg -text $msg  -aspect 99999
  14.     entry $t.e -width 50 -borderwidth 2 -relief sunken
  15.     frame $t.bar 
  16.     button $t.bar.ok -text [Lc "OK"] \
  17.     -command "global EntryDialog_Value
  18.         set EntryDialog_Value \[$t.e get\]
  19.         destroy $t"
  20.     button $t.bar.cancel -text [Lc "Cancel"] \
  21.     -command "global EntryDialog_Value exitVal
  22.     set exitVal 1; set EntryDialog_Value {}
  23.     destroy $t"
  24.     pack append $t.bar \
  25.     $t.bar.ok {left padx 8 pady 8} \
  26.     $t.bar.cancel {right padx 8 pady 8}
  27.     pack append $t \
  28.     $t.msg {top fillx} \
  29.     $t.e {top padx 8 pady 8} \
  30.     $t.bar {bottom fillx}
  31.     bind . <ResizeRequest> {
  32.     wm geometry . 0x0+%x+%y; update
  33.     }
  34.     bind $t <Visibility> "grab -global $t; focus $t.e"
  35.     bind $t.e <KeyPress-Return> " "
  36.     bind $t.e <Enter> "+focus $t.e"
  37.     pack $t -expand true -fill both
  38. }
  39. set EntryDialog_Value ""
  40. set exitVal 0
  41. wm title . ""
  42. wm minsize  . 300 80
  43. set msg ""
  44. foreach m $argv { append msg "$m " }
  45. set msg [string trimright $msg " "]
  46. EntryDialog frame .ed $msg
  47. tkwait window .ed
  48. puts stdout "[string trimright $EntryDialog_Value "\t \n"]"
  49. exit $exitVal
  50.